
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">小区编号</label>
        <div class="layui-input-block">
            <input type="text" name="cid" id="cid" lay-verify="required" lay-reqtext="编号不能为空" placeholder="请输入编号" value="" class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">小区名称</label>
        <div class="layui-input-block">
            <input type="text" name="cname" id="cname" lay-verify="required" lay-reqtext="小区名称不能为空" placeholder="请输入小区名称" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">坐落地址</label>
        <div class="layui-input-block">
            <input type="text" name="address" id="address" lay-verify="required" lay-reqtext="坐落地址不能为空" placeholder="请输入坐落地址" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">占地面积(m²)</label>
        <div class="layui-input-block">
            <input type="text" name="area" id="area" lay-verify="required" lay-reqtext="占地面积不能为空" placeholder="请输入占地面积" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">开发商名称</label>
        <div class="layui-input-block">
            <input type="text" name="creator" id="creator" lay-verify="required" lay-reqtext="开发商名称不能为空" placeholder="请输入开发商名称" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">物业公司名称</label>
        <div class="layui-input-block">
            <input type="text" name="managers" id="managers" lay-verify="required" lay-reqtext="物业公司名称不能为空" placeholder="请输入物业公司名称" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">建设时间</label>
        <div class="layui-input-block">
            <input type="date" name="createTime" id="createTime" lay-verify="required" lay-reqtext="建设时间不能为空" placeholder="请输入建设时间" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">备注</label>
        <div class="layui-input-block">
            <input type="text" name="remark" id="remark" lay-verify="required" lay-reqtext="备注不能为空" placeholder="请输入备注" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
<script src="../../layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        $("#cid").val("${community.cid}");
        $("#cname").val("${community.cname}");
        $("#address").val("${community.address}");
        $("#area").val("${community.area}");
        $("#creator").val("${community.creator}");
        $("#managers").val("${community.managers}");
        $("#createTime").val("${community.createTime}");
        $("#remark").val("${community.remark}");

        form.render();


        //监听提交
        form.on('submit(saveBtn)', function (data) {
            $.ajax({
                type:'post',
                url:'update',
                data:"cid="+data.field.cid+"&cname="+data.field.cname+"&address="+data.field.address+"&area="+data.field.area+"&creator="+data.field.creator
                    +"&managers="+data.field.managers+"&createTime="+data.field.createTime+"&remark="+data.field.remark,
                dataType:'json',
                success(obj){
                    if(obj.code === 0){//成功
                        window.parent.location.reload();
                    }else {
                        layer.alert(obj.msg,{title:'提示信息'})
                    }
                    var iframeIndex = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(iframeIndex);
                }

            })

            return false;

        });


    });
</script>
</body>
</html>
